import React, { Component } from 'react'
import {withRouter} from 'react-router-dom'

class Header extends Component {

    back = () => {
        this.props.history.goBack()
    }

    forward = () => {
        this.props.history.goForward()
    }

    render() {
        return (
            <div className="card-header">
                <h2>React Router Demo</h2>
                <button className="btn btn-primary" onClick={this.back}>后退</button>&nbsp;
                <button className="btn btn-primary" onClick={this.forward}>前进</button>
            </div>
        )
    }
}

// 将一般组件变成路由组件
export default withRouter(Header)
